﻿/*
 * Grid
 * 
 * initial implementation : 20.11.2008
 *
 * Copyright (c) Adam Sida, asida@centrum.cz.
 * All rights reserved.
 * 
 * for license see Petra.Gis.License.txt
 */
using System;
using Petra.Gis.Geometry.Support;
using Petra.Gis.Geometry.GridSupport;
//using Petra.Gis.ReferenceSystemServices.Transformations;


namespace Petra.Gis.Geometry
{
  /// <summary>
  /// Grid cartesian graph (rectangular area) gis data type.
  /// Grid cells holds values, that can be interpretted in map directly (cell value = color)
  /// or indirectly by mapping cell value to some color.
  /// Because of nature of grid data, cell values are not available directly here but <c>GridData</c>
  /// decoder is called and provides many more functions for Grid manipulation.
  /// </summary>
  public class Grid : GeometryBase
  {

    GridDataBase _sourceData;
    //private ImageTransformMatrix _transfMatrix;
    //private string _dataLocation;
    //private RectangleD _bounds;


    public Grid()
    {
      _isEmpty = true;
    }





    public Grid(GridDataBase gridData)
    {

      // grid from grid data
      if (gridData != null)
      {
        _sourceData = gridData;
        _isEmpty = false;
        _valid = true;
      }

    }


    

    /// <summary>
    /// sets/returns current data location of Grid geometry.
    /// this can be either file path or some moniker that might specify various location types
    /// eg. database or url,...
    /// </summary>
    public Uri DataLocation
    {
      get 
      {
        return (_sourceData != null) ? _sourceData.DataLocation : null;
      }
      //set
      //{
      //  if (_sourceData != null)
      //    _sourceData.DataLocation = value; 
      //}
    }





    /// <summary>
    /// sets/returns data for this Grid geometry.
    /// Grid data is cartesian (orthogonal) 2-dimensional plane A x B
    /// where each cell has some value
    /// </summary>
    public GridDataBase Data
    {
      get { return _sourceData; }
      set 
      {
        if (value != null)
        {
          _sourceData = value;
          _isEmpty = false;
          _valid = true;
        }
      }
    }





    internal override BoundingBox getEnvelope()
    {
      _envelope = _sourceData.GetEnvelope();
      return _envelope;
    }




  }
}
